package com.lyz.dataStructure.xiancheng.线程池;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 20:39
 * @Description:
 **/

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/7/4 20:39
 *@Description:
 **/
public class FixedThreadPoolDemo {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(5);
        for(int i=0;i<10;i++){
            final int index =i;
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    try {
                        System.out.println(index);
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    }
}
